﻿using AgencyManagerSystem.Model;
using System.Collections.Generic;
using System.Linq;

namespace AgencyManagerSystem.DataFetcher
{
    public class SupplierMemberFetcher:BaseFetcher<SupplierMemberModel>
    {

        public SupplierMemberFetcher() : base()
        {

        }
        public SupplierMemberModel GetByCode(int supplier,string code)
        {
            Condition[] conditions = new Condition[] { new Condition() { Key = "Code", Op = "=", Value = code },
                                                       new Condition() { Key = "Supplier", Op = "=", Value = supplier } };
            var list = List(conditions);
            if (list.Count > 0)
                return list.First();
            else
                return null;
        }
        public SupplierMemberModel GetByUser(int user)
        {
            Condition[] conditions = new Condition[] { new Condition() { Key = "User", Op = "=", Value = user } };
            var list = List(conditions);
            if (list.Count > 0)
                return list.First();
            else
                return null;
        }
        public IList<SupplierMemberModel> ListBySupplier(int supplier)
        {
            Condition[] conditions = new Condition[] { new Condition() { Key = "Supplier", Op = "=", Value = supplier } };
            var list = List(conditions);
            return list;
        }
    }
}
